// import { toast } from './utils/extendApi'
import './utils/extendApi'
import { setStorage, getStorage, removeStorage, clearStorage, aysncSetStorage, aysncGetStorage, aysncRemoveStorage, aysncClearStorage } from './utils/storage'

App({
  async onLaunch() {
    
    // 当进行冷启动时才会触发 onLaunch ，如果是热启动不会触发 onLaunch
    console.log('onLaunch')

    const updateManager = wx.getUpdateManager()
    updateManager.onUpdateReady(function () {
      wx.showModal({
        title: '更新提示',
        content: '新版本已准备好，是否重启应用？',
        complete: (res) => {
          if (res.cancel) {
            
          }
      
          if (res.confirm) {
            updateManager.applyUpdate()
          }
        }
      })
    })
  },
  async onShow() {
    console.log('onshow')

    // setStorage('name', 'Tom')
    // setStorage('age', 18)
    // const name = getStorage('name')
    // console.log(name)
    // removeStorage('name')
    // clearStorage()

    // aysncSetStorage('name', 'jerry').then(res=> {
    //   console.log(res)
    // }).catch(err => {
    //   console.log(err)
    // })

    // const age = await aysncSetStorage('age', 10)
    // console.log(age)

    // aysncGetStorage('age').then(res => {
    //   console.log(res)
    // })

    // aysncRemoveStorage('name').then(res => {
    //   console.log(res)
    // })

    // const clear = await aysncClearStorage()
    // console.log(clear)

  },
  onHide() {
    console.log('onhide')
  }
})
